//------------------------------------------------------------------------------
// <copyright file="IOExceptionReplaceHandler.cs" company="Damian Antonowicz">
//       copyright © 2010 Damian Antonowicz
// </copyright>
// <author>Damian Antonowicz</author>
// <email>poczta@damianantonowicz.pl</email>
//------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;
using System.Net.Sockets;
using System.Collections.Specialized;
using System.Diagnostics;

namespace DotBeer.Business.Components.Exceptions
{
    [ConfigurationElementType(typeof(CustomHandlerData))]
    public class IOExceptionReplaceHandler : IExceptionHandler
    {
        #region constructors

        public IOExceptionReplaceHandler(NameValueCollection ignore)
        {
        }

        #endregion

        #region public methods

        #region IExceptionHandler Members

        public Exception HandleException(Exception exception, Guid handlingInstanceId)
        {
            if (exception.InnerException is SocketException)
            {
                return new ApplicationException("internet connection has been lost.");
            }
            else
            {
                return new ApplicationException("could not access file system. Check your Windows account permisions.");
            }
        }

        #endregion

        #endregion
    }
}
